package com.wind.trademark.user.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.wind.trademark.base.vo.NodeVo;
import com.wind.trademark.common.vo.PageBean;
import com.wind.trademark.common.vo.PageParam;
import com.wind.trademark.user.model.AccUser;
import com.wind.trademark.user.service.UserService;

@Controller
public class UserController {
	@Autowired
	private UserService userService;
	
	private static final Log log = LogFactory.getLog(UserController.class);

	

	@RequestMapping
	public @ResponseBody PageBean  queryUser(PageParam pageParam,@RequestParam Map<String, Object> params) {
		PageBean pageBean=userService.queryUser(pageParam,params);
		return pageBean;
	}

	@RequestMapping
	public @ResponseBody  AccUser saveOrUpdateUser( AccUser user){
		return userService.saveOrUpdateUser(user);
	}
	@RequestMapping
	public @ResponseBody  AccUser loadUser(Long id){
		return userService.getUser(id);
	}
	@RequestMapping
	public @ResponseBody  List<NodeVo> loadRolesByUserId(Long userId) {
		List<NodeVo> nodeVoList= userService.loadRolesByUserId(userId);
		return nodeVoList;
	}
	@RequestMapping
	public @ResponseBody  boolean saveOrUpdateUserRole(Long userId,Long[] roles) {
		 userService.saveOrUpdateUserRole(userId,Arrays.asList(roles));
		 return true;
	}
	@RequestMapping
	public @ResponseBody  List<AccUser> getAllLawyer() {
		return userService.getAllLawyer();
	}
	
	
	@RequestMapping
	public @ResponseBody  boolean checkAccountUsed(@RequestParam Map<String, Object> params) {
		return userService.checkAccountUsed(params);
	}
	
}
